package com.flying.flow.participant;

import java.util.List;
import java.util.stream.Collectors;

import com.flying.common.util.Codes;
import com.flying.common.util.ServiceHelper;
import com.flying.framework.annotation.Service;
import com.flying.framework.data.Data;

@Service("RoleParticipantProvider")
public class RoleParticipantProvider implements ParticipantProvider {

	@Override
	public List<Participant> getParticipants(String orgCode, String businessType, String source) {
		List<Data> userList = ServiceHelper.invoke("pas", "UserService:findByOrgAndRole", new Data("org_code", orgCode, "role_code", source)).get(Codes.ROWS);
		return userList.stream().map(x -> new Participant() {
			@Override
			public String getId() {
				return x.getString("username");
			}

			@Override
			public String getName() {
				return x.getString("real_name");
			}
			
		}).collect(Collectors.toList());
	}

}
